﻿using RimWorld;
using Verse;
using Verse.AI.Group;
using System.Collections.Generic;
using KTrie;
using System;

namespace RimZombieGirl
{
    public class IncidentWorker_DaoDropBook : IncidentWorker_GiveDaoFriendlyBase
    {
        protected override bool ExecuteFriendlyEvent(IncidentParms parms, Map map, Faction daoFaction)
        {
            // 找到空投点
            IntVec3 dropSpot;
            if (!DropCellFinder.TryFindDropSpotNear(map.Center, map, out dropSpot, allowFogged: false, canRoofPunch: false))
                return false;

            // 创建书籍
            Thing book = BookUtility.MakeBook(ZombieDefOf.RI_CurseCureBook, ArtGenerationContext.Colony, QualityGenerator.Gift);

            List<Thing> list = new List<Thing>();
            list.Add(book);

            IntVec3 intVec = DropCellFinder.TradeDropSpot(map);
            DropPodUtility.DropThingsNear(intVec, map, list, 110, false, true, false, true);

            TaggedString letterText = "RI_DaoDropBook.letterText".Translate();
            TaggedString letterLabel = "RI_DaoDropBook.letterLabel".Translate();
            SendStandardLetter(letterLabel, letterText, LetterDefOf.PositiveEvent, parms, book, Array.Empty<NamedArgument>());

            return true;
        }
    }
}
